<?
	session_start();
    include('gettopmenu.php');
	include('conn.php');
	
	$msg='';
	if($_REQUEST['submit']=='Save Record')
	{
		$user_passold=$_REQUEST['user_passold'];
		$user_pass=$_REQUEST['user_pass'];
		$user_passcnf=$_REQUEST['user_passcnf'];
		$user_id=$_SESSION['username'];
		$sql="select * from usermast where user_id='".$user_id."' and user_pass='".md5($user_passold)."'";
		$res=mysql_query($sql);
		$nrow=mysql_num_rows($res);
		if ($nrow==1)
		{
		if ($user_passcnf = $userpass) {
			$sqlupdate="update usermast set user_pass='".md5($user_pass)."' where user_id='".$user_id."'";
			$resupdate=mysql_query($sqlupdate);
			$msg='Password change successfully';
			}
		else
			{
				$msg = "Password and Confirm Password Does not Match";
			}
		}
		else
		{
			$msg='Old Password is wrong';
		}
	}
?>
<script type="text/javascript" src="customermain.js"></script>
 <script language="javascript">
 function SearchCtrl($scope, $http) {
        $scope.url = 'savepassword.php'; // The url of our search
        // The function that will be executed on button click (ng-click="search()")
        $scope.search = function() {
            // Create the http post request
            // the data holds the keywords
            // The request is a JSON request.  i want the data in $_POST
            $http.post($scope.url, { "user_id" : $scope.user_id,"user_passold" : $scope.user_passold, "user_pass" : $scope.user_pass,"user_passcnf" : $scope.user_paddcnf}).
            success(function(data, status) {
                $scope.status = status;
                $scope.data = data;
                $scope.result = data; // Show result from server in our <pre></pre> element
            }).
            error(function(data, status) {
                $scope.data = data || "Request failed";
                $scope.status = status;         
            });
        };
			//alert(" ");
}
function deletecust(name0)
{
	//alert(name0);
	$.post( "customerdelete.php?", { name: name0})
	.done(function( data ) {
	alert( "Record Deleted ");// + data );
	});
	//var jqxhr = $.post( "customerdelete.php", function() {
	//alert( "success" );
	//})
}
</script>
<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">User Management / Change Password</label></td>
<div  align="center">
			<div ng-controller="SearchCtrl">
			<table  cellpadding="4" id="box-table-a" cellspacing="4" border="1" width="650" bgcolor="#000000" style="background-color:#DFEBF9;">
				<tr><td colspan="3" align="center" style="text-align:center; color:#FF0000;">{{result}}</td></tr>
				<tr>
				  <td colspan="3" align="center" style="text-align:center; font-weight:bold;">Change Password</td>
				</tr>
				<tr bgcolor="#FFFFFF">
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">User Id</label></td>
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
					<label for "Title1" data-icon="p"><?=$_SESSION['username']?></label></td><br>					
<!--					<input type="text" id="email_id" name="email_id" class="smallInput" required= "" ng-model="email_id" placeholder="Email Id" style="width:280px; text-align:left; font-size:12px; font-weight:bold;" /> -->
				</tr>
				<tr bgcolor="#FFFFFF">
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">Old Password <br />
					</label></td>
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
					<input  type="password" id="user_passold" name="user_passold" class="smallInput" required= "" ng-model="user_passold" placeholder="Old Password" style="width:280px; text-align:left; font-size:12px; font-weight:bold;" />
					</td>
				</tr>
				<tr bgcolor="#FFFFFF">
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">Password</label></td>
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
					<input  type="password" id="user_pass" name="user_pass" class="smallInput" required= "" ng-model="user_pass" placeholder="Enter Password" style="width:280px; text-align:left; font-size:12px; font-weight:bold;" />
					</td>
				</tr>
				<tr bgcolor="#FFFFFF">
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">Confirm Password </label></td>
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
					<input  type="password" id="user_passcnf" name="user_passcnf" class="smallInput" required= "" ng-model="user_passcnf" placeholder="Confirm Password" style="width:280px; text-align:left; font-size:12px; font-weight:bold;" />
					</td>
				</tr>
				<tr>
					<td align="center" colspan="3" style="background-color:#BBE2EE">
					<button type="submit" class="btn" ng-click="search();">Save</button>
					</td>
				</tr>
			</table>
		</div>
</div>
</body>
</html>